home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 038a / baswiz17.zip / GDEMO.BAS < prev    next >
BASIC Source File  |  1991-04-01  |  8KB  |  253 lines

  1. '   +----------------------------------------------------------------------+
  2. '   |                                                                      |
  3. '   |         BASWIZ  Copyright (c) 1990-1991  Thomas G. Hanlin III        |
  4. '   |                                                                      |
  5. '   |                       The BASIC Wizard's Library                     |
  6. '   |                                                                      |
  7. '   +----------------------------------------------------------------------+
  8.  
  9.    DECLARE SUB BFont (BYVAL FontNr%)
  10.    DECLARE SUB GetDisplay (Adapter%, Mono%)
  11.    DECLARE SUB G1Banner (St$, X%, Y%, Xmul%, Ymul%)
  12.    DECLARE SUB G1Border (BYVAL Colour%)
  13.    DECLARE SUB G1Box (BYVAL X1%, BYVAL Y1%, BYVAL X2%, BYVAL Y2%, BYVAL Fill%)
  14.    DECLARE SUB G1Color (BYVAL Foregnd%, BYVAL Backgnd%)
  15.    DECLARE SUB G1Ellipse (CenterX%, CenterY%, XRadius%, YRadius%)
  16.    DECLARE SUB G1Line (BYVAL X1%, BYVAL Y1%, BYVAL X2%, BYVAL Y2%)
  17.    DECLARE SUB G1Locate (BYVAL Row%, BYVAL Column%)
  18.    DECLARE SUB G1Mode (BYVAL ModeNr%)
  19.    DECLARE SUB G1PaletteA (BYVAL PaletteNr%)
  20.    DECLARE SUB G1Plot (BYVAL X%, BYVAL Y%)
  21.    DECLARE SUB G1Polygon (X%, Y%, Radius%, Vertices%, Angle!)
  22.    DECLARE SUB G1Write (St$)
  23.    DECLARE SUB G1WriteLn (St$)
  24.    DECLARE SUB G2Color (BYVAL Foregnd%, BYVAL Backgnd%)
  25.    DECLARE SUB G2LoadPCX (File$, Image%(), ErrCode%)
  26.    DECLARE SUB G2Locate (BYVAL Row%, BYVAL Column%)
  27.    DECLARE SUB G2Mode (BYVAL ModeNr%)
  28.    DECLARE SUB G2Put (X%, Y%, Image%())
  29.    DECLARE SUB G2Write (St$)
  30.    DECLARE SUB G2WriteLn (St$)
  31.    DECLARE SUB G7Box (BYVAL X1%, BYVAL Y1%, BYVAL X2%, BYVAL Y2%, BYVAL Fill%)
  32.    DECLARE SUB G7Color (BYVAL Foreground%, BYVAL Background%)
  33.    DECLARE SUB G7Locate (BYVAL Row%, BYVAL Column%)
  34.    DECLARE SUB G7Mode (BYVAL Graphics%)
  35.    DECLARE SUB G7Polygon (X%, Y%, Radius%, Vertices%, Angle!)
  36.    DECLARE SUB G7Write (St$)
  37.    DECLARE SUB G7WriteLn (St$)
  38.    DECLARE SUB G13Box (BYVAL X1%, BYVAL Y1%, BYVAL X2%, BYVAL Y2%, BYVAL Fill%)
  39.    DECLARE SUB G13Color (BYVAL Foreground%, BYVAL Background%)
  40.    DECLARE SUB G13Locate (BYVAL Row%, BYVAL Column%)
  41.    DECLARE SUB G13Mode (BYVAL Graphics%)
  42.    DECLARE SUB G13Polygon (X%, Y%, Radius%, Vertices%, Angle!)
  43.    DECLARE SUB G13Write (St$)
  44.    DECLARE SUB G13WriteLn (St$)
  45.  
  46.    DEFINT A-Z
  47.  
  48.    DEF FNR (X) = INT(RND * X)
  49.  
  50.    RANDOMIZE TIMER
  51.  
  52.    GetDisplay Adapter, Mono
  53.  
  54.    IF Adapter < 3 THEN
  55.       PRINT "Sorry, but you must have a CGA, EGA or VGA display active to run this demo."
  56.       END
  57.    END IF
  58.  
  59.    G1Mode 1                          ' CGA 320x200 mode
  60.    G1PaletteA 0                      ' Green, Red, Yellow palette
  61.  
  62.    BFont 1
  63.    G1Color 1, 0
  64.    G1Banner "BASWIZ", 0, 0, 3, 2
  65.    BFont 0
  66.    G1Color 3, 0
  67.    G1Banner "Copyright (c)1990", 179, 5, 1, 1
  68.    G1Banner "Thomas G. Hanlin", 182, 15, 1, 1
  69.  
  70.    BFont 2
  71.    G1Color 2, 0
  72.    G1Banner "This is the BASIC Wizard's Library.", 0, 40, 1, 1
  73.  
  74.    BFont 1
  75.    G1Color 1, 0
  76.    G1Banner "Flexible text handling is a natural", 0, 68, 1, 1
  77.    G1Banner "aspect of graphics modes.  The BASWIZ", 0, 82, 1, 1
  78.    G1Banner "library takes full advantage of that,", 0, 96, 1, 1
  79.    G1Banner "with a selection of fonts and fast", 0, 110, 1, 1
  80.    G1Banner "full-color text support.", 0, 124, 1, 1
  81.  
  82.    BFont 0
  83.    G1Color 3, 0
  84.    G1Banner "This is CGA mode SCREEN 1, by the way.", 0, 150, 1, 1
  85.  
  86.    BFont 2
  87.    G1Color 2, 0
  88.    G1Banner "Now let's see some graphics!", 0, 170, 1, 1
  89.  
  90.    G1Locate 25, 14
  91.    G1Color 2, 3
  92.    G1Write "Press a key"
  93.  
  94.    DO
  95.    LOOP WHILE LEN(INKEY$)
  96.    DO
  97.       ky$ = INKEY$
  98.    LOOP UNTIL LEN(ky$)
  99.    IF ky$ = CHR$(27) THEN GOTO Done
  100.  
  101.    G1Color 0, 0
  102.    G1Box 0, 30, 319, 189, 1
  103.    G1Color 2, 0
  104.    G1Box 0, 26, 319, 188, 0
  105.  
  106.    G1Color 1, 0
  107.    G1Locate 23, 2
  108.    G1Write "Dots, Lines, Boxes, Ellipses..."
  109.  
  110.    FOR Dot = 1 TO 200
  111.       G1Color FNR(3) + 1, 0
  112.       G1Plot FNR(316) + 2, FNR(140) + 28
  113.    NEXT
  114.  
  115.    FOR Lin = 1 TO 10
  116.       G1Color FNR(3) + 1, 0
  117.       G1Line FNR(316) + 2, FNR(140) + 28, FNR(315) + 3, FNR(139) + 29
  118.    NEXT
  119.  
  120.    FOR Box = 1 TO 10
  121.       G1Color FNR(3) + 1, 0
  122.       X = FNR(250) + 2
  123.       Y = FNR(112) + 28
  124.       G1Box X, Y, X + FNR(60) + 1, Y + FNR(25) + 1, FNR(2)
  125.    NEXT
  126.  
  127.    FOR Ellipse = 1 TO 10
  128.       G1Color FNR(3) + 1, 0
  129.       X = FNR(215) + 40
  130.       Y = FNR(85) + 60
  131.       G1Ellipse X, Y, FNR(25) + 5, FNR(20) + 5
  132.    NEXT
  133.  
  134.    DO
  135.    LOOP WHILE LEN(INKEY$)
  136.    DO
  137.       ky$ = INKEY$
  138.    LOOP UNTIL LEN(ky$)
  139.    IF ky$ = CHR$(27) THEN GOTO Done
  140.  
  141.    G1Color 0, 0
  142.    G1Box 1, 27, 318, 187, 1
  143.  
  144.    G1Color 1, 0
  145.    G1Locate 23, 2
  146.    G1Write "But why stop at the usual?"
  147.  
  148.    FOR Poly = 1 TO 12
  149.       G1Color FNR(3) + 1, 0
  150.       X = FNR(212) + 40
  151.       Y = FNR(90) + 60
  152.       G1Polygon X, Y, FNR(25) + 5, FNR(6) + 3, 3.14159 * RND
  153.    NEXT
  154.  
  155.    DO
  156.    LOOP WHILE LEN(INKEY$)
  157.    DO
  158.       ky$ = INKEY$
  159.    LOOP UNTIL LEN(ky$)
  160.    IF ky$ = CHR$(27) THEN GOTO Done
  161.  
  162.    G2Mode 1                          ' CGA 640x200 mode
  163.    IF Adapter = 3 THEN               ' if CGA...
  164.       G1Border 1                     '    set foreground color to blue
  165.    END IF
  166.    G2Locate 1, 1
  167.    G2Color 1, 0
  168.    G2WriteLn "There are a few additional routines of interest which are designed to work"
  169.    G2WriteLn "only in SCREEN 2 mode at this time.  These are the picture readers, which"
  170.    G2WriteLn "allow you to read in .MAC and .PCX pictures into a GET/PUT image.  Here's"
  171.    G2WriteLn "a sample from GDEMO.PCX:"
  172.  
  173.    REDIM Image(1)
  174.    G2LoadPCX "GDEMO.PCX", Image(), ErrCode
  175.    G2Put 40, 40, Image()
  176.  
  177.    G2Locate 15, 1
  178.    G2WriteLn "Of course, that's not the end of it!  There are many other routines that"
  179.    G2WriteLn "are not included in this demonstration.  One of 'em in particular which you"
  180.    G2WriteLn "may like is a routine to print out a screen (almost any display mode) to"
  181.    G2WriteLn "any Epson-compatible printer.  Another allows you to detect what kind of"
  182.    G2WriteLn "display adapter is attached and whether the display is color or monochrome."
  183.    G2WriteLn ""
  184.    G2WriteLn "See BASWIZ.DOC for more details."
  185.  
  186.    G2Locate 25, 33
  187.    G2Color 0, 1
  188.    G2Write "Press any key"
  189.  
  190.    IF Adapter = 4 THEN                     ' if EGA...
  191.       DO
  192.       LOOP WHILE LEN(INKEY$)
  193.       DO
  194.          ky$ = INKEY$
  195.       LOOP UNTIL LEN(ky$)
  196.       IF ky$ = CHR$(27) THEN GOTO Done
  197.       G7Mode 1                             ' ...put into low-res EGA mode
  198.       G7Color 4, 2
  199.       G7WriteLn "Ah, I see you have an EGA!  Of course,"
  200.       G7Color 0, 3
  201.       G7WriteLn "BASWIZ supports the various EGA modes"
  202.       G7Color 7, 1
  203.       G7WriteLn "as well as the Hercules, CGA and VGA."
  204.       FOR Y = 0 TO 31
  205.          G7Color Y AND 15, 0
  206.          G7Box Y, Y + 64, 319 - Y, (64 - Y) + 120, (Y = 100)
  207.          IF Y > 15 THEN
  208.             G7Polygon Y * 15 - 194, 112, 5, FNR(6) + 3, .75 * 3.141593
  209.             G7Color ((Y XOR 15) AND 15), 0
  210.             G7Polygon Y * 15 - 194, 136, 5, FNR(6) + 3, 0
  211.          END IF
  212.       NEXT
  213.       G7Locate 25, 14
  214.       G7Color 15, 4
  215.       G7Write "Press any key"
  216.    ELSEIF Adapter = 6 THEN                     ' if VGA...
  217.       DO
  218.       LOOP WHILE LEN(INKEY$)
  219.       DO
  220.          ky$ = INKEY$
  221.       LOOP UNTIL LEN(ky$)
  222.       IF ky$ = CHR$(27) THEN GOTO Done
  223.       G13Mode 1                            ' ...put into low-res VGA mode
  224.       G13Color 4, 2
  225.       G13WriteLn "Ah, I see you have a VGA!  Of course,"
  226.       G13Color 0, 3
  227.       G13WriteLn "BASWIZ supports the various VGA modes"
  228.       G13Color 7, 1
  229.       G13WriteLn "as well as Hercules, CGA and EGA."
  230.       FOR Y = 0 TO 31
  231.          G13Color Y + 16, 0
  232.          G13Box Y, Y + 64, 319 - Y, (64 - Y) + 120, (Y = 100)
  233.          IF Y > 15 THEN
  234.             G13Polygon Y * 15 - 194, 112, 5, FNR(6) + 3, .75 * 3.141593
  235.             G13Color 64 - Y, 0
  236.             G13Polygon Y * 15 - 194, 136, 5, FNR(6) + 3, 0
  237.          END IF
  238.       NEXT
  239.       G13Locate 25, 14
  240.       G13Color 15, 4
  241.       G13Write "Press any key"
  242.    END IF
  243.  
  244.    DO
  245.    LOOP WHILE LEN(INKEY$)
  246.    DO
  247.       ky$ = INKEY$
  248.    LOOP UNTIL LEN(ky$)
  249.    IF ky$ = CHR$(27) THEN GOTO Done
  250.  
  251. Done:
  252.    G1Mode 0                          ' restore text mode
  253.